home *** CD-ROM | disk | FTP | other *** search
- property spriteNum
- global stock, tableau
-
- on beginSprite me
- stock = new(script("card pile"))
- stock.cards = shuffle()
- end
-
- on shuffle me
- unshuffled = []
- shuffled = []
- repeat with rank in ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
- repeat with suit in ["hearts", "diamonds", "clubs", "spades"]
- unshuffled.add([#rank: rank, #suit: suit])
- end repeat
- end repeat
- repeat while unshuffled.count > 0
- temp = unshuffled[random(unshuffled.count)]
- shuffled.add(temp)
- unshuffled.deleteOne(temp)
- end repeat
- return shuffled
- end
-
- on mouseDown me
- if sprite(spriteNum).member.name = "backofcard" then
- repeat with num in [12, 28, 44, 60, 76, 92, 108]
- if stock.cards.count = 0 then
- exit repeat
- end if
- puppetSound(3, member("deal card", "100GPak Generic SFX"))
- if tableau[sprite(num).row].getcardcount() > 0 then
- tempnum = tableau[sprite(num).row].getlastcard().spnum + 1
- sprite(tempnum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
- stock.cards.deleteAt(1)
- tableau[sprite(num).row].addCard(tableau[sprite(num).row].getlastcard().spnum + 1)
- else
- sprite(num).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
- stock.cards.deleteAt(1)
- tableau[sprite(num).row].addCard(num)
- end if
- updateStage()
- end repeat
- repeat with u in [26, 42, 58, 74, 90, 106, 122]
- if tableau[sprite(u).row].getcardcount() = 0 then
- temp = [12, 28, 44, 60, 76, 92, 108]
- temp2 = [26, 42, 58, 74, 90, 106, 122]
- ass = temp[temp2.findPos(u)]
- sprite(u).loc = sprite(ass).location
- end if
- sprite(u).loc = tableau[sprite(u).row].getlastcard().location
- end repeat
- if stock.cards.count = 0 then
- sprite(spriteNum).member = member("empty", "playing cards")
- checklose()
- end if
- end if
- end
-